library(FNN)
source('./src/prepare.r')

a <- c()
for (k in seq(13,15,2)) {
    a[k] <- 0
    for (i in 1:25) {
        print(a)
        print('K')
        print(k)
        print('i')
        print(i)

        rows <- sample(nrow(test$x), size = 100, replace = FALSE)
        knn.cl <- knn(train$x, test$x[rows,], train$y, k = k)
        print(sum(knn.cl == test$y[rows]) / length(knn.cl))
        a[k] <- a[k] + (sum(knn.cl == test$y[rows]) / length(knn.cl))
    }
    print(a[k] / 25)
    a[k] <- a[k] / 25
}

plot(a)
